package heap;

import java.io.IOException;

import global.AttrType;

public class StringLabel extends Tuple {

	/**
	 * @param args
	 */
	private static short numFlds = 1;
	private static short [] strSizes = {50};
	private static AttrType [] types = {new AttrType (AttrType.attrString)};
	
	
	public StringLabel () throws InvalidTypeException, InvalidTupleSizeException, IOException {
		super (58);
		this.setHdr(numFlds, types, strSizes);
	}
	
	public StringLabel (Tuple tup) {
		data = tup.getTupleByteArray();
	    tuple_length = tup.getLength();
	    tuple_offset = 0;
	    fldCnt = tup.noOfFlds(); 
	    fldOffset = tup.copyFldOffset();
	}
	
	public String toString (){
		try {
			return this.getStrFld(1);
		} catch (FieldNumberOutOfBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "";
	}
	
	public void addLabel (String label) throws FieldNumberOutOfBoundException, IOException {
		this.setStrFld (1, label);
	}
	
	public String getLabel () {
		try {
			return this.getStrFld(1);
		} catch (FieldNumberOutOfBoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "";
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
